const CryptoJS = require("crypto-js")

function encryptAES(data, aesKey) {
    if (!aesKey) {
        return data;
    }
    return encrypted = getAesString(randomString(64) + data, aesKey, randomString(16));

}

function randomString(len) {
    var retStr = '';
    for (i = 0; i < len; i++) {
        retStr += "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678".charAt(Math.floor(Math.random() * 48));
    }
    return retStr;
}
function getAesString(data, key0, iv0) {
    key0 = key0.replace(/(^\s+)|(\s+$)/g, "");
    var key = CryptoJS.enc.Utf8.parse(key0);
    var iv = CryptoJS.enc.Utf8.parse(iv0);
    var encrypted = CryptoJS.AES.encrypt(data, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}

var pwd = encryptAES("123456", "RbXnynvEfIwE6k2O")
console.log(pwd)